


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > BookDaoImpl</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/highlight-idea.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.pack.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">com.example.bookstorebackend.daoimpl</a>
</div>

<h1>Coverage Summary for Class: BookDaoImpl (com.example.bookstorebackend.daoimpl)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">BookDaoImpl</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (6/6)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (13/13)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<div class="sourceCode" id="sourceCode"><i class="no-highlight">1</i>&nbsp;package com.example.bookstorebackend.daoimpl;
<i class="no-highlight">2</i>&nbsp;
<i class="no-highlight">3</i>&nbsp;import com.example.bookstorebackend.dao.BookDao;
<i class="no-highlight">4</i>&nbsp;import com.example.bookstorebackend.entity.Book;
<i class="no-highlight">5</i>&nbsp;import com.example.bookstorebackend.repository.BookRepository;
<i class="no-highlight">6</i>&nbsp;
<i class="no-highlight">7</i>&nbsp;import org.springframework.beans.factory.annotation.Autowired;
<i class="no-highlight">8</i>&nbsp;import org.springframework.stereotype.Repository;
<i class="no-highlight">9</i>&nbsp;
<i class="no-highlight">10</i>&nbsp;
<i class="no-highlight">11</i>&nbsp;import java.util.List;
<i class="no-highlight">12</i>&nbsp;
<i class="no-highlight">13</i>&nbsp;@Repository
<b class="fc"><i class="no-highlight">14</i>&nbsp;public class BookDaoImpl implements BookDao {</b>
<i class="no-highlight">15</i>&nbsp;    @Autowired
<i class="no-highlight">16</i>&nbsp;    private BookRepository bookRepository;
<i class="no-highlight">17</i>&nbsp;
<i class="no-highlight">18</i>&nbsp;    @Override
<i class="no-highlight">19</i>&nbsp;    public List&lt;Book&gt; getBooks(){
<b class="fc"><i class="no-highlight">20</i>&nbsp;        return bookRepository.getBooks();</b>
<i class="no-highlight">21</i>&nbsp;    }
<i class="no-highlight">22</i>&nbsp;
<i class="no-highlight">23</i>&nbsp;    @Override
<i class="no-highlight">24</i>&nbsp;    public Book getBook(Integer id){
<i class="no-highlight">25</i>&nbsp;
<b class="fc"><i class="no-highlight">26</i>&nbsp;        return bookRepository.getOne(id);</b>
<i class="no-highlight">27</i>&nbsp;//        return bookRepository.findById(id).orElse(null);
<i class="no-highlight">28</i>&nbsp;        }
<i class="no-highlight">29</i>&nbsp;
<i class="no-highlight">30</i>&nbsp;    @Override
<i class="no-highlight">31</i>&nbsp;    public Book getBook(String name){
<b class="fc"><i class="no-highlight">32</i>&nbsp;        Book book=null;</b>
<b class="fc"><i class="no-highlight">33</i>&nbsp;        System.out.println(&quot;searching book&quot;+name+&quot;in Redis.&quot;);</b>
<b class="fc"><i class="no-highlight">34</i>&nbsp;        return bookRepository.findBookByBookName(name);</b>
<i class="no-highlight">35</i>&nbsp;    }
<i class="no-highlight">36</i>&nbsp;    @Override
<i class="no-highlight">37</i>&nbsp;    public Book findBook(String name){
<b class="fc"><i class="no-highlight">38</i>&nbsp;        return bookRepository.findBookByBookNameContains(name);</b>
<i class="no-highlight">39</i>&nbsp;    }
<i class="no-highlight">40</i>&nbsp;    @Override
<i class="no-highlight">41</i>&nbsp;    public Integer purchaseBook(Integer bookId,Integer num){
<b class="fc"><i class="no-highlight">42</i>&nbsp;        Book book=bookRepository.getOne(bookId);</b>
<b class="fc"><i class="no-highlight">43</i>&nbsp;        System.out.println(&quot;Book:&quot;+book);</b>
<b class="fc"><i class="no-highlight">44</i>&nbsp;        Integer price=book.getPrice();</b>
<b class="fc"><i class="no-highlight">45</i>&nbsp;        book.setNumber(book.getNumber()-num);</b>
<b class="fc"><i class="no-highlight">46</i>&nbsp;        bookRepository.save(book);</b>
<b class="fc"><i class="no-highlight">47</i>&nbsp;        return price*num;</b>
<i class="no-highlight">48</i>&nbsp;    }
<i class="no-highlight">49</i>&nbsp;}
</div>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
        var codeBlock = document.getElementById('sourceCode');

        if (codeBlock) {
            hljs.highlightBlock(codeBlock);
        }
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2022-04-14 16:20</div>
</div>
</body>
</html>
